package com.hyc.myvideo.data.adapter.my.statistics;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hyc.data.DateStyle;
import com.hyc.data.DateUtil;
import com.hyc.myvideo.R;
import com.hyc.myvideo.data.adapter.base.BaseListAdapter;
import com.hyc.myvideo.data.api.model.ModelCommissiones;
import com.hyc.myvideo.utils.imguitl.ImgUitl;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 我的提成适配器
 * @author gyb
 * @version 1.0
 * @created 2017/07/26
 */
public class StatisticsCourseAdapter extends BaseListAdapter<ModelCommissiones.Commission> {
    public StatisticsCourseAdapter(Context context, List<ModelCommissiones.Commission> objects) {
        super(context, objects);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            if (getItemViewType(position) == 0) {
                holder = new ViewHolder();
                //无数据展示
                convertView = inflater.inflate(R.layout.adapter_itme_no, parent, false);
                holder.noDataRootLayout = (LinearLayout) convertView.findViewById(R.id.r_no_id);
            } else {
                convertView = inflater.inflate(R.layout.activity_adapter_statistics_course_itme, parent, false);
                holder = new ViewHolder(convertView);
            }
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (hasNoData) {
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(getScreenWidth(), getScreenHeight() * 2 / 3);
            holder.noDataRootLayout.setLayoutParams(lp);
        } else {
            ModelCommissiones.Commission commission = mDataList.get(position);
            if(commission != null){
                ImgUitl.setLocalRoundImg("http://images.haiwainet.cn/20170718/1500342165930656.jpg",holder.imageViewCover,R.dimen.app_img_hw30);
                holder.textViewNickname.setText("昵称");
                holder.textViewMoney.setText("+"+100);
                String date = DateUtil.StringToString("2017-07-26 13:18:00", DateStyle.YYYY_MM_DD);
                holder.textViewDate.setText(date);
            }
        }
        return convertView;
    }

    public static class ViewHolder {
        public ViewHolder() {
        }
        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
        LinearLayout noDataRootLayout;
        //用户头像
        @BindView(R.id.statistics_course_img_cover)ImageView imageViewCover;
        //用户昵称
        @BindView(R.id.statistics_course_t_nickname)TextView textViewNickname;
        //消费金额
        @BindView(R.id.statistics_course_t_money)TextView textViewMoney;
        //消费日期
        @BindView(R.id.statistics_course_t_date)TextView textViewDate;
    }
}
